$(function () {
    $("form").on("submit", function () {

        var data = $("form").serialize();

        $.ajax({
            url: "/reg",
            type: "post",
            data: data
        }).then(function (res) {
            console.log(res);
            let { code, msg, data } = res;
            if (code == 200) {

                //是否跳转到主页
                layer.confirm("注册成功!是否立即登录", {
                    btn: ["确定", "取消"]
                },(index)=>{
                
                    layer.close(index);
                    location.href="./register.html";
                },()=>{

                })


            } else {
                layer.msg(msg);
            }


        })

        return false;
    })
})
